package com.rj.framework.biz;

import com.rj.framework.biz.transformer.PhoneFormatter;
import com.rj.framework.transformer.CustomMapped;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;

@Data
@AutoMapper(target = User.class)
public class UserDTO {
    @CustomMapped(sourceField = "mobileNumber", transformer = PhoneFormatter.class)
    private String formattedPhone;

    public static void main(String[] args) {
        UserDTO userDTO = new UserDTO();
        userDTO.formattedPhone = "123456789010 ";
        //MapstructUtils.convert(userDTO, User.class);
        User user = UserConvert.INSTANCE.to(userDTO);
        System.out.println(user.getEmail());
        System.out.println("123456789010".replaceFirst("(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3"));
    }
}
